﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Text;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Top_Meeting.UI
{
    class TMFont
    {
        public static PrivateFontCollection FontCollection;

        public static Dictionary<string, Font> fonts = new Dictionary<string, Font>();

        public static Font DefaultFont { get { return SystemFonts.DefaultFont; } }

        #region 字段

        #region 黑体

        static Font font_Hei = new Font(new FontFamily("黑体"), 9);
        static Font font_Hei_12 = new Font(new FontFamily("黑体"), 12);
        static Font font_Hei_14 = new Font(new FontFamily("黑体"), 14);
        static Font font_Hei_16 = new Font(new FontFamily("黑体"), 16);
        static Font font_Hei_18 = new Font(new FontFamily("黑体"), 18);
        static Font font_Hei_20 = new Font(new FontFamily("黑体"), 20);

        #endregion


        #region 宋体

        static Font font_Son = new Font(new FontFamily("宋体"), 9);
        static Font font_Son_12 = new Font(new FontFamily("宋体"), 12);
        static Font font_Son_14 = new Font(new FontFamily("宋体"), 14);
        static Font font_Son_16 = new Font(new FontFamily("宋体"), 16);
        static Font font_Son_18 = new Font(new FontFamily("宋体"), 18);
        static Font font_Son_20 = new Font(new FontFamily("宋体"), 20);

        #endregion


        #region 微软雅黑

        static Font font_YaHei = new Font(new FontFamily("微软雅黑"), 9);
        static Font font_YaHei_12 = new Font(new FontFamily("微软雅黑"), 12);
        static Font font_YaHei_14 = new Font(new FontFamily("微软雅黑"), 14);
        static Font font_YaHei_16 = new Font(new FontFamily("微软雅黑"), 16);
        static Font font_YaHei_18 = new Font(new FontFamily("微软雅黑"), 18);
        static Font font_YaHei_20 = new Font(new FontFamily("微软雅黑"), 20);

        #endregion

        #endregion


        #region 属性 

        public static Font Font_Hei { get => font_Hei; }
        public static Font Font_Hei_12 { get => font_Hei_12; }
        public static Font Font_Hei_14 { get => font_Hei_14; }
        public static Font Font_Hei_16 { get => font_Hei_16; }
        public static Font Font_Hei_18 { get => font_Hei_18; }
        public static Font Font_Hei_20 { get => font_Hei_20; }

        #endregion


        #region PUBLIC_METHOD

        public static void Init()
        {
            FontCollection = Helper.LoadFont();

            for (int i = 0; i < FontCollection.Families.Length; i++)
            {
                FontFamily ff = FontCollection.Families[i];

                if (!fonts.ContainsKey(ff.Name))
                {
                    fonts[ff.Name] = new Font(ff, 10);
                }
            }
        }

        public static Font GetFont(string fontName, int fontSize = 10)
        {
            if (!fonts.ContainsKey(fontName))
                return DefaultFont;

            return new Font(fonts[fontName].FontFamily, fontSize);
        }

        #endregion
    }


}

